package com.un10.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.un10.entity.User;
import com.un10.entity.receivinglist;
import com.un10.service.receivinglistService;
import com.un10.util.Result;

@Controller
public class receivinglistController {

	@Autowired
	receivinglistService receivinglistService;

	@RequestMapping("/houtai/getAllreceivinglist")
	@ResponseBody
	public Object getPropicinfo(@RequestParam("page") int page, @RequestParam("limit") int limit,
			@RequestParam("userName") String userName) {

		List<receivinglist> receivinglist = receivinglistService.findAllreceiving((page - 1) * limit, limit, userName);

		if (userName == null || userName == "") {
			userName = null;
		}
		int count = receivinglistService.getCount();
		System.out.println(userName);
		com.un10.util.Result res = new com.un10.util.Result(0, "", count, receivinglist);
		return res;
	}

	@RequestMapping("/houtai/receivingAdd")
	@ResponseBody
	public Object findreceivingAdd(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("consignee"));
		int i = receivinglistService.findreceivingAdd(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/receivingUpdate")
	@ResponseBody
	public Object updateUser(@RequestParam Map<String, Object> map) {

		int i = receivinglistService.findreceivingUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/receivingDelete")
	@ResponseBody
	public Object userdelete(@RequestParam("htID") Integer htID) {
		int i = receivinglistService.findreceivingDelete(htID);
		Result res = new Result(0, "", i, true);
		return res;
	}
}
